//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.pancm;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.turbo.TurboFilter;
import ch.qos.logback.core.spi.FilterReply;
//import com.webank.deposit.Bootstrap.Hook;
//import com.webank.deposit.dto.enumeration.sys.MDCKey;
import org.apache.commons.lang.StringUtils;
import org.slf4j.MDC;
import org.slf4j.Marker;

public class MapperRelevelFilter extends TurboFilter {
    private static final String MAPPER_PACK = ".mapper.";
    private Level logLevel;

    public MapperRelevelFilter() {
    }

    public FilterReply decide(Marker marker, Logger logger, Level level, String format, Object[] params, Throwable t) {
        if (level.isGreaterOrEqual(Level.INFO)) {
            return FilterReply.NEUTRAL;
        } else if (this.logLevel.isGreaterOrEqual(Level.INFO) && logger.getName().contains(".mapper.")) {
            String mdcLevel = MDC.get("logLevel");
            return StringUtils.isNotEmpty(mdcLevel) && Level.DEBUG.isGreaterOrEqual(Level.toLevel(mdcLevel)) ? FilterReply.NEUTRAL : FilterReply.DENY;
        } else {
            return FilterReply.NEUTRAL;
        }
    }

    public Level getLogLevel() {
        return this.logLevel;
    }

    public void setLogLevel(Level logLevel) {
        this.logLevel = logLevel;
    }
}